<template>
  <div class="pagebox">
    <crumbs @goBack="goBack" :superiorMenu="['生产管理']" currentMenu="合格品清单" style="margin-bottom: 12px"></crumbs>
    <a-card :bordered="false" size="small">
      <div class="topBox">
        <div>
          <a-button @click="handleShowFilter" icon="filter"
            >筛选 <span class="filter-num" style="margin-left: 5px">{{ ' ' + filteredNums() }}</span></a-button
          >
          <a-button @click="showColumn" icon="unordered-list" style="margin-left: 10px"> 设置列 </a-button>
        </div>
        <!-- <div>
          <a-button style="margin-right: 10px">导出</a-button>
        </div> -->
      </div>
      <a-table
        row-key="id"
        :key="tableKey"
        :columns="columns"
        :data-source="tableData"
        :pagination="false"
        :scroll="{ x: scrollX, y: 'calc(100vh - 366px)' }"
        :row-selection="{ selectedRowKeys: selectedRowKeys, columnTitle: ' ', onChange: onSelectChange }"
        @change="handleChange"
        :components="drag(columns, 'QUALIFIED_PRODUCT_LIST')"
      >
        <div slot="batchCode" slot-scope="text, record" class="btn-text ant-table-row-cell-ellipsis" :title="text" @click="batchRecord(record)">{{text|| '-'}}</div>
        <!-- 操作人 -->
        <span :title="record.operatorName" slot="operatorId" slot-scope="text, record">
          {{  record.operatorName }}
        </span>
        <span :title="record.applicantName" slot="applicantId" slot-scope="text, record">
          {{  record.applicantName }}
        </span>
        <!-- 数字千分位 -->
        <span slot="num" :title="record.num" :style="{ color: setColor(record.type) }" slot-scope="text, record">
          {{ numFormat(record.num) }}
        </span>
        <!-- 6个字符控制 超出。。。 -->
        <span slot="goodsName" :title="record.goodsName" slot-scope="text, record">
          {{  record.goodsName }}
        </span>
        <span slot="spec" :title="record.spec" slot-scope="text, record">
          {{  record.spec }}
        </span>
        <span slot="goodsBasicUnit" :title="record.basicUnitText" slot-scope="text, record">
          {{  record.basicUnitText }}
        </span>
        <span
          slot="orderCode"
          :title="record.orderCode"
          slot-scope="text, record"
          class="btn-text"
          @click="handleDetail(record)"
        >
          {{ record.orderCode }}
        </span>
        <!-- 人员选择 -->
        <div slot="selectPeople" slot-scope="{ confirm, clearFilters, column }" class="searchWorkOreder">
          <j-select-user-by-dep
            @changeRow="userPrinc"
            v-model="principalStr"
            :seldep="true"
            :modalWidth="1000"
            :limit="5"
            :multi="true"
            v-if="column.dataIndex == 'operatorId'"
          ></j-select-user-by-dep>
          <j-select-user-by-dep
            @changeRow="userCreate"
            v-model="createStr"
            :seldep="true"
            :modalWidth="1000"
            :limit="5"
            :multi="true"
            v-if="column.dataIndex == 'applicantId'"
          ></j-select-user-by-dep>
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="peopleIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />
        <!-- 输入框搜索 -->
        <div slot="searchInput" slot-scope="{ selectedKeys, confirm, clearFilters, column }" class="searchWorkOreder">
          <a-input
            placeholder="请输入"
            v-model="filterForm[column.dataIndex]"
            style="width: 188px; display: block"
            @pressEnter="handleSearch"
          />
          <a-button
            type="primary"
            style="width: 80px; margin-left: 20px; display: block"
            @click="() => handleSearch(selectedKeys, confirm, column.dataIndex, clearFilters)"
          >
            搜索
          </a-button>
        </div>
        <a-icon
          slot="searchIcon"
          slot-scope="filtered"
          type="search"
          :style="{ color: filtered ? '#108ee9' : undefined }"
        />

        <span slot="action" slot-scope="text, record">
          <a @click="putInStorage(record)">申请入库</a>
        </span>
      </a-table>
    </a-card>
    <div
      class="uni-card"
      :style="{ position: 'fixed', bottom: 0, right: 0, left: collapsed ? '79px' : '208px', background: '#fff',paddingLeft: '54px', }"
    >
      <div style="display: inline-block">
        <a-checkbox :indeterminate="listIndeterminate" :checked="listCheckAll" @change="onCheckAllChange"></a-checkbox>
        <!-- <span class="pubColor" style="margin: 0 24px">批量完成</span><span class="pubColor">批量作废</span> -->
        <span style="margin-left: 8px">
          <span @click="putInStorage(selectedRowKeys)" class="pubColor" style="margin: 0 10px">批量申请入库</span>
          {{ `已选 ${selectedRowKeys.length}/${total} 项` }}
          <span @click="clearArr" class="pubColor" style="margin: 0 10px">清空</span>
        </span>
      </div>
      <div style="display: inline-block; float: right">
        <a-pagination
          :total="total"
          v-model="current"
          :page-size-options="pageSizeOptions"
          :page-size="pageSize"
          @change="onChangePage"
          @showSizeChange="onShowSizeChange"
          show-quick-jumper
          show-size-changer
        />
      </div>
    </div>
    <SetColumn
      columnName="设置列"
      ref="SetColumn"
      v-if="showSetColumn"
      @sureBtn="sureBtn"
      @cancelBtn="showSetColumn = false"
    />
    <a-drawer placement="right" width="500" :visible="showFilter" @close="closeFilter">
      <div class="filter-body">
        <div slot="title" class="uni-card filter-tit">
          筛选 <span class="filter-num">{{ filteredNums(1) }}</span>
        </div>
        <div class="uni-card" v-if="filteredNums(1) > 0" style="background: #fff">
          <div v-for="(item, i) in filteredList" :key="i" v-show="item.text" class="tag-wrap">
            <span class="filter-tag" @click="delFiltered(item.key)">
              <span class="tag-text">{{ `${item.title}：${item.text}` }}</span>
              <a-icon type="close" style="float: right" />
            </span>
          </div>
        </div>
        <div style="overflow-y: scroll; flex: 1; padding: 0">
          <div class="uni-card" style="background: #fff">
            <a-form-model ref="ruleForm" layout="vertical" :model="filterForm">
              <a-form-model-item label="工单编号">
                <a-input v-model="filterForm.orderCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="批次编号">
                <a-input v-model="filterForm.batchCode" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="产品名称">
                <a-input v-model="filterForm.goodsName" placeholder="请输入" :maxLength="30" />
              </a-form-model-item>
              <a-form-model-item label="规格">
                <a-input v-model="filterForm.spec" placeholder="请输入" />
              </a-form-model-item>
              <a-form-model-item label="操作人">
                <j-select-user-by-dep
                  @changeRow="principalChange"
                  v-model="principalStr"
                  :seldep="true"
                  :modalWidth="1000"
                  :limit="5"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="提交人">
                <j-select-user-by-dep
                  @changeRow="createChange"
                  v-model="createStr"
                  :seldep="true"
                  :modalWidth="1000"
                  :limit="5"
                  :multi="true"
                ></j-select-user-by-dep>
              </a-form-model-item>
              <a-form-model-item label="计划完成时间">
                <a-range-picker
                  date-format="YYYY-MM-DD"
                  :placeholder="['请输入', '请输入']"
                  v-model="modelEndTime"
                  style="width: 100%"
                  @change="endTimeChange"
                />
              </a-form-model-item>
            </a-form-model>
          </div>
        </div>
        <div class="footer-submit">
          <a-button class="margin-btn" @click="resetFilter">重置</a-button>
          <a-button type="primary" @click="handleFilter">确定</a-button>
        </div>
      </div>
    </a-drawer>
    <batch-production ref="BatchProduction"></batch-production>
    <windowDetail ref="windowDetail"></windowDetail>
    <windowForm ref="windowForm" @refresh="handleSearch"></windowForm>
  </div>
</template>
<script>
import SetColumn from '@/pubComponent/SetColumn.vue'
import { getNewColumns, subStrText, numFormat, camelCase2UnderLine } from '@/utils/util'
import { qualifiedList } from '@/api/goodsManagement'
import crumbs from '@/components/crumbs.vue'
import { mapState } from 'vuex'
import tableDragResize from '@/mixins/tableDragResize'
import BatchProduction from '@/pubComponent/BatchProduction'
import windowDetail from '@/views/workManagement/workOrder/workOrderDetail'
import windowForm from '@/views/workManagement/qualifiedProduct/qualifiedProductForm'
// 表头
/* 打开设置列面板123 */
const columnsValue = [
  {
    title: '工单编号',
    dataIndex: 'orderCode',
    sorter: true,
    key: 'orderCode',
    width: 170,
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'orderCode',
    },
  },
  {
    title: '批次编号',
    dataIndex: 'batchCode',
    key: 'batchCode',
    width: 170,
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'batchCode',
    },
  },
  {
    title: '产品编号',
    width: 170,
    dataIndex: 'goodsCode',
    key: 'goodsCode',
    ellipsis: true,
  },
  {
    title: '产品名称',
    align: 'left',
    width: 170,
    dataIndex: 'goodsName',
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'goodsName',
    },
  },
  {
    title: '规格',
    align: 'left',
    width: 100,
    ellipsis: true,
    dataIndex: 'spec',
    scopedSlots: {
      filterDropdown: 'searchInput',
      filterIcon: 'searchIcon',
      customRender: 'spec',
    },
  },
  {
    title: '基本单位',
    width: 100,
    align: 'left',
    ellipsis: true,
    dataIndex: 'goodsBasicUnit',
    scopedSlots: { customRender: 'goodsBasicUnit' },
  },
  {
    title: '数量',
    width: 120,
    align: 'left',
    ellipsis: true,
    sorter: true,
    dataIndex: 'num',
    scopedSlots: { customRender: 'num' },
  },
  {
    title: '操作人',
    dataIndex: 'operatorId',
    width: 120,
    key: 'operatorId',
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'selectPeople',
      filterIcon: 'peopleIcon',
      customRender: 'operatorId',
    },
  },
  {
    title: '提交人',
    dataIndex: 'applicantId',
    width: 120,
    key: 'applicantId',
    ellipsis: true,
    scopedSlots: {
      filterDropdown: 'selectPeople',
      filterIcon: 'peopleIcon',
      customRender: 'applicantId',
    },
  },
  {
    title: '提交时间',
    sorter: true,
    dataIndex: 'applyTime',
    key: 'applyTime',
    width: 180,
    ellipsis: true,
  },
  // {
  //   title: '操作',
  //   fixed: 'right',
  //   dataIndex: 'action',
  //   align: 'center',
  //   scopedSlots: { customRender: 'action' },
  // },
]
const actionArr = [
  {
    title: '操作',
    fixed: 'right',
    width: 100,
    dataIndex: 'action',
    align: 'center',
    scopedSlots: { customRender: 'action' },
  },
]
export default {
  mixins: [tableDragResize],
  name: 'qualifiedProductList', //合格品清单列表
  components: { crumbs, SetColumn, BatchProduction, windowDetail, windowForm },
  data() {
    return {
      // 排序
      sortForm: {
        sortType: '',
        sortColumn: '',
      },
      modelEndTime: [], //计划完成时间
      // 人员组件 操作人
      principalStr: '',
      showPrincipalStr: '', //筛选-负责人
      //人员组件 提交人
      createStr: '',
      showCreateStr: '', //提交人

      subStrText,
      numFormat,
      columns: [
        {
          title: '工单编号',
          dataIndex: 'orderCode',
          key: 'orderCode',
          width: 170,

          sorter: true,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'orderCode',
          },
        },
        {
          title: '批次编号',
          dataIndex: 'batchCode',
          key: 'batchCode',
          width: 170,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'batchCode',
          },
        },
        {
          title: '产品名称',
          align: 'left',
          dataIndex: 'goodsName',
          width: 160,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'searchInput',
            filterIcon: 'searchIcon',
            customRender: 'goodsName',
          },
        },
        {
          title: '数量',
          align: 'left',
          width: 120,
          ellipsis: true,
          sorter: true,
          dataIndex: 'num',
          scopedSlots: { customRender: 'num' },
        },
        {
          title: '提交人',
          dataIndex: 'applicantId',
          key: 'applicantId',
          width: 120,
          ellipsis: true,
          scopedSlots: {
            filterDropdown: 'selectPeople',
            filterIcon: 'peopleIcon',
            customRender: 'applicantId',
          },
        },
        {
          title: '提交时间',
          dataIndex: 'applyTime',
          width: 180,
          key: 'applyTime',
          sorter: true,
          ellipsis: true,
        },
        // {
        //   title: '操作',
        //   fixed: 'right',
        //   dataIndex: 'action',
        //   width: 100,
        //   // align: 'center',
        //   scopedSlots: { customRender: 'action' },
        // },
      ],
      tableData: [],
      selectedRowKeys: [],
      selectArr: [],
      //全选按钮
      listIndeterminate: false,
      listCheckAll: false,
      showFilter: false, // 筛选抽屉
      // 筛选form
      filterForm: {
        orderCode: '', //工单编号
        batchCode: '', //批次编号
        goodsName: '', //产品名称
        spec:'',       //规格
        applicantId: '', //提交人
        operatorId: '', //操作人
        planEndTime: null, //计划完成时间
      },
      filteredFormLable: {
        orderCode: '工单编号', //工单编号
        batchCode: '批次编号',
        goodsName: '产品名称', //物料名称
        spec:'规格',       //规格
        applicantId: '提交人', //提交人
        operatorId: '操作人', //操作人
        planEndTime: '计划完成时间', //计划完成时间
      },
      // 分页
      current: 1,
      total: 100,
      pageSize: 10,
      pageSizeOptions: ['10', '20', '30', '40', '50'],
      showSetColumn: false,
      tableKey: 1.9
    }
  },
  computed: {
    scrollX() {
      let xnum = 0
      for (let item of this.columns) {
        xnum += Number(item.width) || 0
      }
      return xnum
    },
    ...mapState({
      collapsed: (state) => state.user.collapsed,
    }),
    hasSelected() {
      return this.selectedRowKeys.length > 0
    },
    filteredList() {
      // debugger
      let list = []
      for (let key in this.filterForm) {
        if (this.filteredFormLable[key] == '计划完成时间') {
          if (this.filterForm[key] != null) {
            list.push({
              title: this.filteredFormLable[key],
              text: this.filterForm[key],
              key,
            })
          }
        } else if (this.filterForm[key] != '' && this.filteredFormLable[key] == '操作人') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showPrincipalStr,
            key,
          })
        } else if (this.filterForm[key] != '' && this.filteredFormLable[key] == '提交人') {
          list.push({
            title: this.filteredFormLable[key],
            text: this.showCreateStr,
            key,
          })
        } else {
          list.push({
            title: this.filteredFormLable[key],
            text: this.filterForm[key],
            key,
          })
        }
      }
      console.log(list, 'list')
      return list
    },
  },
  created() {
    this.initData()
    this.requestData()
  },
  methods: {
    // 批次生产记录弹窗列表
    batchRecord(record) {
      let obj = {
        id: record.batchId,
        orderId: record.orderId,
        batchCode: record.batchCode,
      }
      this.$refs.BatchProduction.showModal(obj,'I')
    },
    setColor(s) {
      console.log(s, 'ssssssssssssssss')
      let cor = {
        report: '#191f25',
        compromise: '#ff4d4f',
      }
      return cor[s] || ''
    },
    /* 申请入库 */
    putInStorage(v) {
      if (v instanceof Array) {
        if (v.length > 0) {
          // console.log(v.toString(), 'v.toString()')
          // this.$router.push({
          //   path: '/workManagement/qualifiedProduct/qualifiedProductForm',
          //   query: { id: v.toString() },
          // })
          this.$refs.windowForm.initForm(v.toString())
        } else {
          this.$antdMessage.warning('请勾选需要批量申请入库的数据')
        }
      } else {
        this.$refs.windowForm.initForm(v.id)
        // this.$router.push({
        //   path: '/workManagement/qualifiedProduct/qualifiedProductForm',
        //   query: { id: v.id },
        // })
      }
    },
    //   选人 操作人
    // 负责人
    userPrinc(storeVals, row) {
      this.filterForm.operatorId = ''
      console.log('这里限制性了')
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }
      if (newArr.length > 0) {
        this.filterForm.operatorId = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showPrincipalStr = arrTwo.join(',')
      }
      this.handleSearch()
    },
    //选人 操作人 抽屉方法
    principalChange(storeVals, row) {
      this.filterForm.operatorId = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }
      if (newArr.length > 0) {
        this.filterForm.operatorId = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showPrincipalStr = arrTwo.join(',')
      }
    },
    // 选人 提交人
    userCreate(storeVals, row) {
      this.filterForm.applicantId = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }
      if (newArr.length > 0) {
        this.filterForm.applicantId = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showCreateStr = arrTwo.join(',')
      }
      this.handleSearch()
    },
    // 选人 提交人 筛选
    createChange(storeVals, row) {
      this.filterForm.applicantId = ''
      let newArr = []
      let arrTwo = []
      for (let item of row) {
        newArr.push(item.id)
        arrTwo.push(item.realname)
      }
      if (newArr.length > 0) {
        this.filterForm.applicantId = newArr.join(',')
      }
      if (arrTwo.length > 0) {
        this.showCreateStr = arrTwo.join(',')
      }
    },
    // 计划完成时间
    endTimeChange(a, b) {
      if (!b[0] && !b[1]) {
        this.modelEndTime = []
        this.filterForm.planEndTime = null
      } else {
        this.filterForm.planEndTime = b
      }
    },
    // 详情
    handleDetail(v) {
      let query = {id: v.orderId}
      this.$refs.windowDetail.initDetail(query)
    },
    // 加载数据
    initData() {
      /* 设置列 */
      var oldValue = localStorage.getItem(this.BUSI_CONST.Entity.QUALIFIED_PRODUCT_LIST)
      this.columns = getNewColumns(columnsValue, JSON.parse(oldValue), actionArr, this.columns)
    },
    requestData() {
      /* 请求列表数据 */
      let applyTimeBegin = null
      let applyTimeEnd = null
      if (this.filterForm.planEndTime && this.filterForm.planEndTime.length > 0) {
        applyTimeBegin = this.filterForm.planEndTime[0] + ' ' + '00:00:00'
        applyTimeEnd = this.filterForm.planEndTime[1] + ' ' + '23:59:59'
      }
      // let newFilterForm = this.filterForm
      // delete newFilterForm.planEndTime
      let parameter = {
        applyTimeBegin: applyTimeBegin,
        applyTimeEnd: applyTimeEnd,
        ...this.filterForm,
        pageNo: this.current,
        pageSize: this.pageSize,
        ...this.sortForm,
      }
      qualifiedList(parameter).then((res) => {
        if (res.code == 200) {
          this.tableData = res.result.records
          this.total = res.result.total
        }
      })
    },
    // 导航栏
    goBack() {},
    handleSearch(selectedKeys, confirm, dataIndex, clearFilters) {
      // confirm() //用来关闭搜索弹窗
      // clearFilters() //用来重置搜索内容
      // console.log('这都是啥00：', selectedKeys)
      // console.log('这都是啥11：', confirm)
      // console.log('这都是啥22：', dataIndex)
      // console.log('这都是啥33：', clearFilters)
      this.current = 1
      this.requestData()
    },
    /* 打开筛选 */
    handleShowFilter() {
      this.showFilter = true
    },
    /* 关闭筛选 */
    closeFilter() {
      this.showFilter = false
    },
    /* 确定筛选 */
    handleFilter() {
      this.handleSearch()
      this.showFilter = false
    },
    /* 删除已选 */
    delFiltered(key) {
      if (this.filteredFormLable[key] == '操作人') {
        this.principalStr = ''
        this.showPrincipalStr = ''
        this.filterForm[key] = ''
      } else if (this.filteredFormLable[key] == '提交人') {
        this.createStr = ''
        this.showCreateStr = ''
        this.filterForm[key] = ''
      } else if (this.filteredFormLable[key] == '计划完成时间') {
        this.modelEndTime = []
        this.filterForm[key] = []
      } else {
        this.filterForm[key] = ''
      }
    },
    /* 重置筛选 */
    resetFilter() {
      this.filterForm = {
        orderCode: '', //工单编号
        goodsName: '', //产品名称
        spec:'',
        planEndTime: null, //计划完成时间
        applicantId: '', //提交人
        operatorId: '', //操作人
      }
      this.principalStr = '' //筛选-操作人
      this.showPrincipalStr = '' //筛选-操作人
      this.createStr = '' //筛选-提交人
      this.showCreateStr = '' //筛选-提交人
      this.modelEndTime = [] //计划完成时间
      // this.showFilter = false
      this.handleSearch()
    },
    filteredNums(n) {
      let nums = 0
      if (n) {
        for (let key in this.filterForm) {
          if (
            this.filterForm[key] != '' &&
            key != 'createBy' &&
            this.filterForm[key] != null &&
            this.filterForm[key] != undefined
          ) {
            nums += 1
          }
        }
      } else {
        for (let key in this.filterForm) {
          if (this.filterForm[key] != '' && this.filterForm[key] != null && this.filterForm[key] != undefined) {
            nums += 1
          }
        }
      }
      return nums
    },
    /* 打开设置列面板123 */
    showColumn() {
      this.showSetColumn = true
      this.$nextTick(() => {
        this.$refs.SetColumn.paramsData(columnsValue, this.BUSI_CONST.Entity.QUALIFIED_PRODUCT_LIST, this.columns)
      })
    },
    /* 设置列 */
    sureBtn(emitArr) {
      this.columns = getNewColumns(columnsValue, emitArr, actionArr)
      localStorage.setItem(this.BUSI_CONST.Entity.QUALIFIED_PRODUCT_LIST, JSON.stringify(emitArr))
      this.tableKey += 1
    },
    // table
    // 排序
    handleChange(pagination, filters, sorter, { currentDataSource }) {
      console.log('看看这是啥33：', sorter)
      if (sorter.order) {
        let sortType = ''
        if (sorter.order == 'ascend') {
          sortType = 'ASC'
        } else {
          sortType = 'DESC'
        }
        this.sortForm = {
          sortType: sortType,
          sortColumn: camelCase2UnderLine(sorter.columnKey),
        }
        this.requestData()
      } else {
        this.sortForm = {
          sortType: '',
          sortColumn: '',
        }
        this.requestData()
      }
    },
    // table选择
    onSelectChange(selectedRowKeys, selectedRows) {
      this.selectedRowKeys = selectedRowKeys
      this.checkBoxStatus()
    },
    // 全选
    onCheckAllChange(e) {
      if (e.target.checked) {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
          this.selectedRowKeys.push(item.id)
        }
      } else {
        for (let item of this.tableData) {
          this.selectedRowKeys = this.selectedRowKeys.filter((each) => {
            return each != item.id
          })
        }
      }
      this.checkBoxStatus()
    },
    // 清空
    clearArr() {
      this.selectedRowKeys = []
      this.checkBoxStatus()
    },
    checkBoxStatus() {
      if (this.selectedRowKeys.length == 0) {
        this.listIndeterminate = false
        this.listCheckAll = false
      } else {
        let tableIds = []
        for (let item of this.tableData) {
          tableIds.push(item.id)
        }
        let checkValue = this.isInclude(tableIds, this.selectedRowKeys)
        if (checkValue) {
          this.listIndeterminate = false
          this.listCheckAll = true
        } else {
          this.listIndeterminate = true
          this.listCheckAll = false
        }
      }
    },
    isInclude(aa, bb) {
      return aa.every((item) => {
        return bb.some((sub) => {
          return sub === item
        })
      })
    },
    // 分页
    onChangePage(current, pageSize) {
      this.current = current
      this.requestData()
    },
    onShowSizeChange(current, pageSize) {
      this.pageSize = pageSize
      this.current = current
      this.requestData()
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.flex(@jc,@ai,@fd:row) {
  display: flex;
  justify-content: @jc;
  align-items: @ai;
  flex-direction: @fd;
}
.table-operations {
  margin-bottom: 16px;
}

.table-operations > button {
  margin-right: 8px;
}
.topBox {
  .flex(space-between, center);
  margin-bottom: 16px;
}
.searchWorkOreder {
  .flex(flex-start, center);
  padding: 8px;
}
.pubColor {
  font-size: 14px;
  color: #1890ff;
  cursor: pointer;
}
.pagebox {
  /deep/ .ant-card-body {
    height: calc(100vh - 226px);
    overflow: hidden;
    padding: 20px 16px;
  }
}
.header {
  width: 150%;
  margin: -12px -12px @distance4;
}
.backBox {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  .backC {
    cursor: pointer;
    display: flex;
    align-items: center;
  }
}
.j-table-force-nowrap {
  margin-top: @distance1;
}
.btns {
  margin-left: @distance5;
}
.right-btn {
  float: right;
  display: flex;
  justify-content: flex-end;
}
.mg-left {
  margin-left: @distance3;
}
.filter-tit {
  background: #fff;
  border-bottom: 1px solid @greyBorder;
  font-size: @fontSize4;
}
.filter-num {
  color: @normalFont;
}
.filter-body {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.margin-btn {
  margin-right: @distance5;
}
.filter-tag {
  display: inline-block;
  position: relative;
  padding: 8px 10px;
  border-radius: 4px;
  font-size: @fontSize1;
  line-height: @fontSize1;
  max-width: 100%;
  background: @greyBg;
  color: @titFont;
  cursor: pointer;
  .tag-text {
    display: inline-block;
    padding-right: 20px;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .anticon-close {
    position: absolute;
    right: 8px;
    top: 8px;
  }
}
.tag-wrap:nth-of-type(n + 2) {
  margin-top: 10px;
}
</style>
